﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LaughingDog.GameObjects;
using Microsoft.Xna.Framework;

namespace LaughingDog.Components
{
    public class Joint : Behaviour
    {        
        protected FarseerGames.FarseerPhysics.Dynamics.Joints.Joint mJoint;
        protected Vector2 mInitialAnchor = Vector2.Zero;

        /// <summary>
        /// Enables or disables this Joint.
        /// </summary>
        public new Boolean Enabled { get { return mJoint.Enabled; } set { mJoint.Enabled = false; } }        

        /// <summary>
        /// Gets or sets a value defining the maximum allowed value that JointError can reach before the joint is broken. 
        /// </summary>
        public Single Breakpoint { get { return mJoint.Breakpoint; } set { mJoint.Breakpoint = value; } }

        /// <summary>
        /// Gets or sets the coefficient used to allow joint softness
        /// </summary>
        public Single Softness { get { return mJoint.Softness; } set { mJoint.Softness = value; } }

        /// <summary>
        /// Gets or sets the coefficient that determines how strongly the error will be corrected.
        /// </summary>
        public Single BiasFactor { get { return mJoint.BiasFactor; } set { mJoint.BiasFactor = value; } }

        /// <summary>
        /// Creates a new instance of a Joint component.
        /// </summary>
        /// <param name="gameObject">The GameObject this Component should be attached to.</param>
        public Joint(GameObject gameObject)
            : base(gameObject)
        {
        }

        /// <summary>
        /// Sets the initial anchor point of the joint. Call this before Create().
        /// </summary>
        /// <param name="initialAnchor">The anchor point</param>
        public void SetInitialAnchor(Vector2 initialAnchor)
        {
            mInitialAnchor = initialAnchor;
        }

        /// <summary>
        /// Creates the Joint component. 
        /// </summary>
        public virtual void Create()
        {
        }
    }
}
